$('.glyphicon-votei').click(function () {
	var el = $(this)
	var elClass = 'glyphicon-votei-on';
	if (el.hasClass(elClass))
		el.removeClass(elClass);
	else 
		el.addClass(elClass);
	
	$.post('/candidatos/votar', {id : el.data('id')});
	return false;
});

$(document).on('click', '.dialog-delete', function(e) {
	var element = $(this);
    bootbox.dialog({
	  message: "Deseja realmente excluir?",
	  buttons: {
	    yes: {
	      label: "Sim",
	      className: "btn-danger",
	      callback: function() {
	    	  document.location.href = element.data('action');
	      }
	    },
	    no: {
	      label: "Não",
	      className: "btn-default"
	    }
	  }
    });
    return false;
});

$(document).on('submit', '.form-import', function(e) {
    var form = $(this);
    var inputFile = form.find('input[type=file]');
    var btn = form.find('button[type=submit]');
	if ($(inputFile).val()) {
	    btn.button('loading');
		return true;
	}
    return false;
});

$(document).on('click', '.btn-loading', function(e) {
    $(this).button('loading');
});